VERSION 5.00
Begin VB.UserControl txtProducto 
   BackColor       =   &H80000013&
   ClientHeight    =   690
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   4830
   ScaleHeight     =   690
   ScaleWidth      =   4830
   Begin VB.TextBox txtPro_Denom 
      BackColor       =   &H8000000B&
      Enabled         =   0   'False
      Height          =   285
      Left            =   960
      TabIndex        =   2
      Top             =   240
      Width           =   3135
   End
   Begin VB.CommandButton cmdBuscar 
      Height          =   375
      Left            =   4200
      Picture         =   "txtProducto.ctx":0000
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   120
      Width           =   495
   End
   Begin VB.TextBox txtPro_codigo 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   0
      MaxLength       =   8
      TabIndex        =   0
      Top             =   240
      Width           =   855
   End
   Begin VB.Label lblCliente 
      BackColor       =   &H80000013&
      Caption         =   "Producto"
      Height          =   255
      Left            =   0
      TabIndex        =   3
      Top             =   0
      Width           =   2055
   End
End
Attribute VB_Name = "txtProducto"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Event Validado()

Private Sub cmdBuscar_Click()
dlgConsultaProductos.Show vbModal
If dlgConsultaProductos.pro_codigo <> 0 Then
    txtPro_codigo.text = dlgConsultaProductos.pro_codigo
    txtPro_codigo_Validate (False)
Else
    limpiar
End If
End Sub



Private Sub txtPro_codigo_LostFocus()
    txtPro_codigo_Validate (True)
End Sub

Private Sub txtPro_codigo_Validate(Cancel As Boolean)
If txtPro_codigo.text <> "" Then
    Dim rec As New ADODB.Recordset
    Set rec = Nothing
    rec.ActiveConnection = cn
    rec.Open "select pro_Denom from producto where pro_codigo = " & txtPro_codigo.text
  
    If rec.RecordCount <> 0 Then
      rec.MoveFirst
      txtPro_Denom = rec!pro_denom
        RaiseEvent Validado
    Else
        MsgBox "No existe el producto", vbOKOnly, "Error"
        txtPro_codigo.text = ""
        txtPro_Denom.text = ""
        txtPro_codigo.SetFocus
    End If

Else
txtPro_Denom.text = ""
End If
End Sub

Public Sub limpiar()
txtPro_codigo.text = ""
txtPro_Denom.text = ""
End Sub

Private Sub txtPro_codigo_KeyPress(KeyAscii As Integer)
If IsNumeric(Chr(KeyAscii)) = False And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub

Public Sub deshabilitar()
txtPro_codigo.text = ""
txtPro_Denom.text = ""
txtPro_codigo.Enabled = False
cmdBuscar.Enabled = False
End Sub

Public Sub habilitar(b As Boolean)
txtPro_codigo.Enabled = b
cmdBuscar.Enabled = b
If Not b Then
    txtPro_codigo.text = ""
    txtPro_Denom.text = ""
    
End If
End Sub

Public Function text() As String
text = txtPro_codigo.text
End Function

Public Function settext(texto As String)
txtPro_codigo.text = texto
Call txtPro_codigo_Validate(False)
End Function
Public Sub validar()
Call txtPro_codigo_Validate(False)
End Sub

Private Sub txtPro_codigo_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
    SendKeys "{TAB}"
End If
End Sub

Public Sub focus()
    txtPro_codigo.SetFocus
End Sub
